# provides table access via number methods
#
# exit
class Fixnum
  # the table class Fixnum is using
  @@table=nil

  def e x
    return eval(x)
  end

  # col y has formatting sym ?
  def is? y,sym
    self.table.is?(self,y,sym)
  end

  # sets table for Fixnum
  def Fixnum.set_table table
    @@table=table
  end

  # get cell value at row self, column y
  def col y
    begin
      @@table.get(self,y)
    rescue => e
      e
    end
  end

  # returns format of cell at row self, column y
  def get_format y
     table.format_at self,y
  end

  # method to clear formats
  # see Table::RTable.clear_format
  # *foo => opt1,opt2 ...
  def clear *foo
    @@table.clear_format self,*foo
  end

  # return the used column length of row self
  def length
    @@table.row_col_length self
  end

  # sets format of either row => all cells, row => cell or row => cells
  # c => :all,Range or Fixnum
  # *opts => opt1,opt2 ...
  # see Table::RTable.smart_format 
  def format c=:all,*opts
    @@table.smart_format(self,c,*opts)
  end

  # append cell and set the cell to value v
  # returns Array of the [column number, last column #]
  # where last column # is usually == column #
  # see Table::RTable.fill
  def push v,*opts
    @@table.push v,self,*opts
  end

  # set the value of cell self,y to v
  # does not behave like push (longer strings than aTable.cell_len do get foramtted for proper display)
  def set v,y
    begin
      @@table.fill_xy v,self,y
    rescue => e
      e
    end
  end

  # returns the Table::RTable of Fixnum
  def table
    @@table
  end

  # show cell self,y as table.show would show the table
  # displays formatted values
  # see Table::RTable.show_cell
  def show y,*opts
    @@table.show_cell self,y,*opts
  end

  # show all cells in row self as aTable.show would show the table
  # displays formatted values
  # see Table::RTable.show_row
  def show_all *opts
    @@table.show_row self,*opts
  end

  # Returns the hash of columns for @@table at row self
  def cols
    @@table.rows[self][:cols]
  end

  alias :get :col
  alias :col_len :length
end